package com.douqu.game.main.server.entity;

import com.douqu.game.core.controller.PlayerController;
import com.douqu.game.core.e.E_ServerType;
import com.douqu.game.core.entity.activity.MatchBaseInfo;
import com.douqu.game.core.netty.NettyConnection;
import com.douqu.game.core.protobuf.SGCommonProto;
import com.douqu.game.main.GameServer;
import com.douqu.game.main.server.ActivityCampManager;
import com.douqu.game.main.server.WorldManager;

/**
 * @Author: Bean
 * @Description:
 * @Date: 2018-03-07 17:39
 */
public class ServerInfoActivity extends ServerInfo
{
    public ServerInfoActivity(E_ServerType serverType, NettyConnection connection, int port)
    {
        super(serverType, connection, port);
    }


    @Override
    public void destroy()
    {
        super.destroy();

        PlayerController playerController = null;
        WorldManager worldManager = GameServer.getInstance().getWorldManager();

        for(MatchBaseInfo baseInfo : ActivityCampManager.getInstance().getPlayerMap().values())
        {
            playerController = worldManager.getPlayerController(baseInfo.getObjectIndex());
            if(playerController != null && playerController.getBattleData() != null)
            {
                if(playerController.getBattleData().getBattleType() == SGCommonProto.E_BATTLE_TYPE.BATTLE_TYPE_SPAN_CAMP_VALUE)
                {
                    playerController.clearBattle();
                }
            }
        }
    }
}
